﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;
using System.ComponentModel;

namespace IconEditorXBAP.ModelicaElements
{
    //Constants.iconProgram:
    //type LinePattern= enumeration(None, Solid, Dash, Dot, DashDot, DashDot , DashDotDot );
    //type Arrow= enumeration(None, Open, Filled, Filled , Half );
    //type FillPattern= enumeration(None, Solid, Horizontal, Vertical, Cross, Forward, Backward, CrossDiag, HorizontalCylinder, VerticalCylinder, VerticalCylinder , Sphere );
    //type BorderPattern= enumeration(None, Raised, Sunken, Sunken , Engraved );
    //type TextStyle= enumeration(Bold, Italic, Italic , Underline );
    public enum LinePattern { None, Solid, Dash, Dot, DashDot,  DashDotDot };
    public enum Arrow { None, Open, Filled, Half };
    public enum FillPattern { None, Solid, Horizontal, Vertical, Cross, Forward, Backward, CrossDiag, HorizontalCylinder, VerticalCylinder, Sphere };
    public enum BorderPattern { None, Raised, Sunken, Engraved };
    public enum TextStyle { Bold, Italic, Underline };

    public class BaseElement : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(info));
        }

        #endregion
    }

    //record GraphicItem
    //  Boolean visible=true;
    //end GraphicItem;
    class GraphicItem : BaseElement
    {
        public bool visible = true;
    }

    //record CoordinateSystem
    //  Real extent[2,2];
    //end CoordinateSystem;
    class CoordinateSystem : BaseElement
    {
        public double[,] extent = new double[2, 2];

        public CoordinateSystem(double[,] _extent)
        {
            extent = _extent;
        }
    }

    //record Icon
    //  CoordinateSystem coordinateSystem(extent={{-10.0,-10.0},{10.0,10.0}});
    //end Icon;
    class Icon : BaseElement
    {
        CoordinateSystem coordinateSystem = new CoordinateSystem(new double[,] { { -10.0, -10.0 }, { 10.0, 10.0 } });
    }

    //record Line
    //  Boolean visible=true;
    //  Real points[:,2];
    //  Integer color[3]={0,0,0};
    //  LinePattern pattern=LinePattern.Solid;
    //  Real thickness=0.25;
    //  Arrow arrow[2]={Arrow.None,Arrow.None};
    //  Real arrowSize=3.0;
    //  Boolean smooth=false;
    //end Line;
    public class Line : BaseElement
    {
        public bool visible { get; set; } // = true;
        public PointCollection points { get; set; } //= new PointCollection();
        public Color color { get; set; } //= Color.FromArgb(0, 0, 0, 0);
        public LinePattern pattern { get; set; } //= LinePattern.Solid;
        public double thickness { get; set; } //= 0.25;
        public Arrow[] arrow { get; set; } //= new Arrow[] { Arrow.None, Arrow.None };
        public double arrowSize { get; set; } //= 3.0;
        public bool smooth { get; set; } //= false;
                
        public Line()
        {
        }

        public Line(
            bool _visible,
            PointCollection _points,
            Color _color,
            LinePattern _pattern, 
            double _thickness, 
            Arrow[] _arrow,
            double _arrowSize,
            bool _smooth)
        {
            visible = _visible;
            points = _points;
            color = _color;
            pattern = _pattern;
            thickness = _thickness;
            arrow = _arrow;
            arrowSize = _arrowSize;
            smooth = _smooth;
        }
    }

    //record Polygon
    //  Boolean visible=true;
    //  Integer lineColor[3]={0,0,0};
    //  Integer fillColor[3]={0,0,0};
    //  LinePattern pattern=LinePattern.Solid;
    //  FillPattern fillPattern=FillPattern.None;
    //  Real lineThickness=0.25;
    //  Real points[:,2];
    //  Boolean smooth=false;
    //end Polygon;
    class Polygon : BaseElement
    {
        public bool visible = true;
        public Color lineColor = Color.FromArgb(0, 0, 0, 0);
        public Color fillcolor = Color.FromArgb(0, 0, 0, 0);
        public LinePattern pattern = LinePattern.Solid;
        public FillPattern fillPattern = FillPattern.None;
        public double lineThickness = 0.25;
        public PointCollection points = new PointCollection();
        public bool smooth = false;
    }

    //record Rectangle
    //  Boolean visible=true;
    //  Integer lineColor[3]={0,0,0};
    //  Integer fillColor[3]={0,0,0};
    //  LinePattern pattern=LinePattern.Solid;
    //  FillPattern fillPattern=FillPattern.None;
    //  Real lineThickness=0.25;
    //  BorderPattern borderPattern=BorderPattern.None;
    //  Real extent[2,2];
    //  Real radius=0.0;
    //end Rectangle;
    public class Rectangle : BaseElement
    {
        public bool visible { get; set; }
        public Color lineColor { get; set; }
        public Color fillColor { get; set; }
        public LinePattern pattern { get; set; }
        public FillPattern fillPattern { get; set; }
        public double lineThickness { get; set; }
        public BorderPattern borderPattern { get; set; }
        public double[,] extent { get; set; }
        public double radius { get; set; }

        public Rectangle()
        {
        }

        public Rectangle(
            bool _visible,
            Color _lineColor,
            Color _fillColor,
            LinePattern _pattern,
            FillPattern _fillPattern,
            double _lineThickness,
            BorderPattern _borderPattern,
            double[,] _extent,
            double _radius)
        {
            visible = _visible;
            lineColor = _lineColor;
            fillColor = _fillColor;
            pattern = _pattern;  // not yet implemented
            fillPattern = _fillPattern;  // not yet implemented
            lineThickness = _lineThickness;
            borderPattern = _borderPattern;  // not yet implemented
            extent = _extent;
            radius = _radius;
        }
    }

    //record Ellipse
    //  Boolean visible=true;
    //  Integer lineColor[3]={0,0,0};
    //  Integer fillColor[3]={0,0,0};
    //  LinePattern pattern=LinePattern.Solid;
    //  FillPattern fillPattern=FillPattern.None;
    //  Real lineThickness=0.25;
    //  Real extent[2,2];
    //end Ellipse;
    public class Ellipse : BaseElement
    {
        public bool visible { get; set; }
        public Color lineColor { get; set; }
        public Color fillColor { get; set; }
        public LinePattern pattern { get; set; }
        public FillPattern fillPattern { get; set; }
        public double lineThickness { get; set; }
        public double[,] extent { get; set; }

        public Ellipse()
        {
        }

        public Ellipse(
            bool _visible,
            Color _lineColor, 
            Color _fillColor,
            LinePattern _pattern, 
            FillPattern _fillPattern,
            double _lineThickness, 
            double[,] _extent)
        {
            visible = _visible;
            lineColor = _lineColor;
            fillColor = _fillColor;
            pattern = _pattern;  // not yet implemented
            fillPattern = _fillPattern;  // not yet implemented
            lineThickness = _lineThickness;
            extent = _extent;  // not yet implemented
        }
    }
    
    //record Text
    //  Boolean visible=true;
    //  Integer lineColor[3]={0,0,0};
    //  Integer fillColor[3]={0,0,0};
    //  LinePattern pattern=LinePattern.Solid;
    //  FillPattern fillPattern=FillPattern.None;
    //  Real lineThickness=0.25;
    //  Real extent[2,2];
    //  String textString;
    //  Real fontSize=0.0;
    //  String fontName="";
    //  TextStyle textStyle[:];
    //end Text;
    public class Text : BaseElement
    {
        public bool visible { get; set; }
        public Color lineColor { get; set; }
        public Color fillColor { get; set; }
        public LinePattern pattern { get; set; }
        public FillPattern fillPattern { get; set; }
        public double lineThickness { get; set; }
        public double[,] extent { get; set; }
        public String textString { get; set; }
        public double fontSize { get; set; }
        public String fontName { get; set; }
        public List<TextStyle> textStyle { get; set; }

        public Text()
        {
        }

        public Text(
            bool _visible,
            Color _lineColor, 
            Color _fillColor,
            LinePattern _pattern, 
            FillPattern _fillPattern,
            double _lineThickness, 
            double[,] _extent,
            String _textString, 
            double _fontSize,
            String _fontName, 
            List<TextStyle> _textStyle)
        {
            visible = _visible;
            lineColor = _lineColor;
            fillColor = _fillColor;
            pattern = _pattern;  // not yet implemented
            fillPattern = _fillPattern;  // not yet implemented
            lineThickness = _lineThickness;  // not yet implemented
            extent = _extent;
            textString = _textString;
            fontSize = _fontSize;
            fontName = _fontName;  // not yet implemented 
            textStyle = _textStyle;  // not yet implemented 
        }
    }

    //record Bitmap
    //  Boolean visible=true;
    //  Real extent[2,2];
    //  String fileName="";
    //  String imageSource="";
    //end Bitmap;
    class Bitmap : BaseElement
    {
        public bool visible = true;
        public double[,] extent = new double[2, 2];
        public String fileName = "";
        public String imageSource = "";  // not yet implemented 
    }
}
